package com.lsmo.android.carfans.activity.car;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.lsmo.android.carfans.R;
import com.lsmo.android.carfans.view.car.CarNavigationView;

/**
 * 车型首页
 * @author SYX
 */
public class CarMainAcitivity extends ActivityGroup{

	private static CarMainAcitivity instance;
	private static int navContainerId;
	public CarNavigationView carNavView;
	private LinearLayout container = null;
	private Intent navIntent;
	
	/**
	 * 导航栏控件实例
	 * 
	 * @return
	 */
	public static CarMainAcitivity getInstance() {
		if (instance == null) {
			instance = new CarMainAcitivity();
		}
		return instance;
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		carNavView = new CarNavigationView(this);
		setContentView(carNavView);
		
		setNavLinearBackGroundRes(R.drawable.custom_title_bg);//导航栏背景
		setLeftImgBtnBackGroundRes(R.drawable.auto_icon);//左侧图标
		setNavigationTitle("车型");//设置标题
		setRightImgBtnBackGroundRes(R.drawable.loading);//右侧图标
		
		navContainerId = carNavView.getNavContainer().getId();
		container = carNavView.getNavContainer();
		container.removeAllViews();
		navIntent = new Intent(this,SelectCarAcitivity.class);
		View neView = getLocalActivityManager()
			.startActivity("SelectCarAcitivity", navIntent).getDecorView();
		container.addView(neView);
	}
	
	
	

	//导航栏标题
	public void setNavigationTitle(String navTitle) {
		carNavView.setNavigationText(navTitle);
	}
	//导航栏背景
	public void setNavLinearBackGroundRes(int res){
		carNavView.setNavLinearResId(res);
	}
	//左侧图标
	public void setLeftImgBtnBackGroundRes(int res){
		carNavView.setLeftNavigationResId(res);
	}
	//右侧图标
	public void setRightImgBtnBackGroundRes(int res){
		carNavView.setRightNavigationResId(res);
	}
}
